<?php
/*
 * Session variables:
 * $_SESSION['database'] [string] = database name of the current tutorial centre
 * $_SESSION['type'] [string] = user type of the logged in user
 * $_SESSION['authorised'] [boolean] = whether or not the current user is logged in
 * $_SESSION['user'] [string] = the username/ email of the logged in user
 * $_SESSION['message'] [string] = message sent by the server
 * $_POST['oldpass'] [string] = the old password of the user
 * $_POST['newpass1'] [string] = the new password of the user
 * $_POST['newpass2'] [string] = for verification of the new password
 */
session_start();

if(isset($_SESSION['authorised']) && $_SESSION['authorised'] == true)
{
	?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Home</title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
<style>
.nav {
	width: 210px;
	height: auto;
	border: thin solid #09C;
	margin-left: 10px;
	text-align: center;
}

.mainline {
	width: 712px;
	height: auto;
	text-align: center;
}
</style>
<script type="text/javascript">
                        function checkPasswordMatch() {            
                            var pass1 = document.getElementById('newpass1');
                            var pass2 = document.getElementById('newpass2');
                            var message = document.getElementById('passwordmessage');

                            if(pass1.value == pass2.value) {
                                pass2.style.backgroundColor = "#66cc66";
                                message.style.color = "#66cc66";
                                message.innerHTML = "Passwords Match!";
                            } else {	
                                pass2.style.backgroundColor = "#ff6666";
                                message.style.color = "#ff6666";
                                message.innerHTML = "Passwords Do Not Match!";
                            }
                        }
                    </script>
</head>
<body bgcolor="#FFFFFF">
	<center>

		<div id="wrapper">
			<div id="header">
				<h1></h1>
			</div>

			<div id="header2">
				<h3></h3>
			</div>

			<div id="nav">
			<?php
			if($_SESSION['type'] == 'student')
			{
				include 'student_navigation.php';
			}
			elseif($_SESSION['type'] == 'administrator')
			{
				include 'admin_navigation.php';
			}
			elseif($_SESSION['type'] == 'parent')
			{
				include 'parent_navigation.php';
			}
			elseif($_SESSION['type'] == 'tutor')
			{
				include 'tutor_navigation.php';
			}
			?>
			</div>

			<div id="mainline">
				<h4>Change User Password</h4>
				<div id="body">
					<form action="changepassword_execute.php" method="post">
						<h5 align="left">
						<?php
						if(isset($_SESSION['message']) && $_SESSION['message'] != ""){
							$message = $_SESSION['message'];
							echo "$message";
							unset($_SESSION['message']);
						}
						?>
						</h5>
						<table width="550" cellpadding="2" class="infotable"
							align="center">
							<tr>
								<th align="left">Old Password *:</th>
								<td><input type="password" size="40" maxlength="256"
									name="oldpass" /></td>
							</tr>
							<tr>
								<th align="left">New Password *:</th>
								<td><input type="password" size="40" maxlength="256"
									id="newpass1" name="newpass1" /></td>
							</tr>
							<tr>
								<th align="left">Repeat Password *:</th>
								<td><input type="password" size="40" maxlength="256"
									id="newpass2" name="newpass2"
									onkeyup="checkPasswordMatch(); return false;" /></td>
							</tr>

						</table>
						<input name="submit" type="submit" value="Change" />
					</form>

					<p align="justify">
						<br />
					</p>
				</div>
			</div>
			<br class="clearfloat"> <br />

			<div id="footer">
				<p align="center">
					Tutorial Business Manager: info@tbms.com <br />Credits/Engineers:
					Aquino, Chloebelle; Dela Cruz, Roy Erwin; Maliwanag, Ranyel Bryan;
					Manzano, Audrey Ann; Ng, Sheila Regine<br /> <br />copyright 2011
				</p>
			</div>


		</div>
	</center>
</body>
						<?php
}
else
{
	header('Location: index.php');
}
?>
